package cn.zhentao.service.impl;

import cn.zhentao.mapper.DeliverymanNotificationsMapper;
import cn.zhentao.pojo.DeliverymanNotifications;
import cn.zhentao.service.IDeliverymanNotificationsService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 配送员消息通知表 服务实现类
 * </p>
 *
 * @author mp
 * @since 2025-06-22
 */
@Service
public class DeliverymanNotificationsServiceImpl extends ServiceImpl<DeliverymanNotificationsMapper, DeliverymanNotifications> implements IDeliverymanNotificationsService {

    @Override
    public boolean markAsRead(Long id) {
        DeliverymanNotifications notification = new DeliverymanNotifications();
        notification.setId(id);
        notification.setIsRead(1);
        return this.updateById(notification);
    }

    @Override
    public boolean markAllAsRead(Long deliverymanId) {
        UpdateWrapper<DeliverymanNotifications> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("deliveryman_id", deliverymanId).set("is_read", 1);
        return this.update(updateWrapper);
    }
}
